package com.karaoke.android.home.fragment

import android.app.Presentation
import android.content.Context
import android.os.Bundle
import android.view.Display
import android.view.WindowManager
import com.karaoke.android.home.databinding.VideoPresentationBinding
import com.karaoke.android.home.vm.VideoViewModel

/**
 * Created by allen on 2017/4/24.
 */

class VideoFragment(context: Context, display: Display) : Presentation(context, display)
{
    val viewModel: VideoViewModel by lazy { VideoViewModel() }
    lateinit var mBinding: VideoPresentationBinding

    init
    {
        window.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
                        WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED)
        window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT)
        window.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL)
    }

    override fun onCreate(savedInstanceState: Bundle?)
    {
        super.onCreate(savedInstanceState)
        mBinding = VideoPresentationBinding.inflate(layoutInflater)
        setContentView(mBinding.root)
        mBinding.viewModel = viewModel
        viewModel.onCreate()
    }

    override fun onStart()
    {
        super.onStart()
        viewModel.onStart()
    }

    override fun onStop()
    {
        super.onStop()
        viewModel.onStop()
    }

    override fun dismiss()
    {
        super.dismiss()
        viewModel.onDestroy()
    }
}
